package pikes.core;

import java.io.IOException;

public class PrinterAsAppendableAdapter implements Appendable {

	private Printer typeWriter = null;

	public PrinterAsAppendableAdapter(final Printer typeWriter) {
		super();
		this.typeWriter = typeWriter;
	}

	public final Appendable append(final CharSequence csq) throws IOException {
		return append(csq, 0, csq.length());
	}

	public final Appendable append(final char c) throws IOException {
		typeWriter.print(c);
		return this;
	}

	public final Appendable append(final CharSequence csq, final int start, final int end) throws IOException {
		for (int i = start; i < end; i++) {
			append(csq.charAt(i));
		}
		return this;
	}

}
